#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5e6 + 5;

int n, k;
int a[N];
int kth_element(int l, int r, int k) {
  if (l == r) return a[l];

  int pos = l + rand() % (r + 1 - l);
  int x = a[pos];
  swap(a[l], a[pos]);
  int i = l, j = r;
  while (i < j) {
    while (i < j && a[j] >= x) j--;
    swap(a[i], a[j]);
    while (i < j && a[i] <= x) i++;
    swap(a[i], a[j]);
  }
  int mid = i;
  if (mid == k)
    return a[mid];
  else if (mid > k)
    return kth_element(l, mid - 1, k);
  else
    return kth_element(mid + 1, r, k);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  rep(i, 1, n) cin >> a[i];
  cout << kth_element(1, n, k + 1);
  return 0;
}